package com.csust.travel.mapper;

import com.csust.travel.entity.Gift;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface GiftMapper {

    @Select("select * from gift order by update_time desc")
    List<Gift> findAllItem();

    @Delete("delete from gift where id = #{id}")
    void delItem(Integer id);

    @Insert("insert into gift values(null,#{gift_name},#{gift_price},#{gift_jd_url},#{gift_person},now(),now())")
    void saveItem(Gift item);

    @Select("select * from gift where id = #{id}")
    Gift findOne(Integer id);

    @Update("update gift set gift_name=#{gift_name},gift_price=#{gift_price},gift_jd_url =#{gift_jd_url},gift_person=#{gift_person},create_time=#{create_time} where id = #{id}")
    void editItem(Gift item);

    @Select("<script>" +
            "SELECT * FROM gift WHERE " +
            "gift_name REGEXP #{regex} OR " +
            "gift_person REGEXP #{regex}" +
            "</script>")
    List<Gift> findByString(@Param("regex") String regex);


}
